# -*- coding: utf-8 -*-
# @Time : 2022-05-23 16:19
# @Author : Z
# @Function : app关键字测试
from Keywords.app_keys import App

app=App()
# 连接Appium
app.run_appium()
# 启动qq程序
app.run_app('{"platformName":"Android","platformVersion":"7.1.2","deviceName":"127.0.0.1:62001",'
           '"appPackage":"com.tencent.mobileqq","appActivity":".activity.SplashActivity","noReset":"true"}')
app.sleep("1")

# 登录
app.input("请输入QQ号码或手机或邮箱", "2707630641")
app.input("密码 安全","7812977zwx")
app.click("登 录")
app.sleep("2")
# app.screenshot()

# 搜索
app.click("搜索")
app.click("com.tencent.mobileqq:id/et_search_keyword")
app.input("com.tencent.mobileqq:id/et_search_keyword","632232258")
app.click("com.tencent.mobileqq:id/ikf")
app.click("//*[@text='【特斯汀】课程顾问-卡卡']")
app.click("加好友")

# 取消搜索
app.click("com.tencent.mobileqq:id/ivTitleBtnLeftButton")
app.click("com.tencent.mobileqq:id/ivTitleBtnLeft")
app.click("返回")
app.click("com.tencent.mobileqq:id/btn_cancel_search")

# 退出登录
app.click("帐户及设置")
app.sleep("1")
app.click("设置")
app.sleep("1")
app.click("帐号管理")
app.sleep("1")
app.click("退出当前帐号按钮")
app.sleep("1")
app.click("//*[@text=\"退出登录\"]")
app.sleep("1")
app.click("//*[@text=\"确定退出\"]")
app.sleep("1")
app.screen_shot()
app.quit()
app.sleep("1")
app.kill_appium()
